package stream;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

/**
 * @author Hongliang Zhu
 * @create 2021-08-01 13:57
 */
public class Demo4 {

    public static void main(String[] args) {

        List<String> list = Arrays.asList("adnm", "admmt", "pot", "xbangd", "weoujgsd");

        // 最长的字符串
        System.out.println(list.stream().max(Comparator.comparing(String::length)).get());

        List<Integer> nums = Arrays.asList(7, 6, 9, 4, 11, 6);
        // 自然排序
        System.out.println(nums.stream().max(Integer::compareTo).get());


        List<Person> personList = new ArrayList<Person>();
        personList.add(new Person("Tom", 8900, 23, "male", "New York"));
        personList.add(new Person("Jack", 7000, 25, "male", "Washington"));
        personList.add(new Person("Lily", 7800, 21, "female", "Washington"));
        personList.add(new Person("Anni", 8200, 24, "female", "New York"));
        personList.add(new Person("Owen", 9500, 25, "male", "New York"));
        personList.add(new Person("Alisa", 7900, 26, "female", "New York"));


        System.out.println(personList.stream().max(Comparator.comparingInt(Person::getSalary)).get());


        System.out.println(nums.stream().filter(x -> x > 6).count());


    }

}
